package com.weixin.engine.interceptor;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;

import javax.annotation.Resource;
import java.util.List;

/**
 * 拦截器
 *
 * @author wangchunhui
 * @date 2023/5/31 15:20
 */
//@Configuration
public class ArgumentResolverConfig implements WebMvcConfigurer {

    @Resource
    private ArgumentResolver argumentResolver;

//    @Bean
//    @ConditionalOnMissingBean
//    public ArgumentResolver argumentResolver(List<HttpMessageConverter<?>> httpMessageConverters) {
//        RequestResponseBodyMethodProcessor handlerMethodArgumentResolver = new RequestResponseBodyMethodProcessor(httpMessageConverters);
//        return new ArgumentResolver(handlerMethodArgumentResolver);
//    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(argumentResolver);
    }
}
